package cn.yanghan.scheduling;

import cn.yanghan.service.IKillCourseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

//发布秒杀课程的定时任务
@Component
@Slf4j
public class PublicCourseTask {

    @Autowired
    private IKillCourseService killCourseService;

    //每5秒执行一次
    @Scheduled(cron = "0/5 * * * * ?")
    //@Async
    public void publicCourse2Redis(){
        log.info("发送秒杀任务到redis,每5秒执行一次");
        killCourseService.publicCourse2Redis();
    }

}
